package com.huluobo.higt4demo1911.presenter;


import android.util.Log;

import com.blankj.utilcode.util.SizeUtils;
import com.huluobo.higt4demo1911.App;
import com.huluobo.higt4demo1911.bean.VideoBean;
import com.huluobo.higt4demo1911.contract.VideoContract;
import com.huluobo.higt4demo1911.core.db.VideoBeanDao;
import com.huluobo.higt4demo1911.core.http.call.CallObserver;
import com.huluobo.higt4demo1911.core.mvp.BasePresenter;
import com.huluobo.higt4demo1911.model.VideoModel;

import java.util.List;

import io.reactivex.disposables.Disposable;

/**
 * Created by lc on 2022/4/20.
 */
public class VideoPresenter extends BasePresenter<VideoContract.Model, VideoContract.View> {
    public VideoPresenter(VideoContract.View mView) {
        super(new VideoModel(), mView);
    }

    public void list() {
        mModel.requestVideos(new CallObserver<List<VideoBean>>() {
            @Override
            public void onSubscribe(Disposable d) {
                addDisposable(d);
            }

            @Override
            public void success(List<VideoBean> bean) {
                for (VideoBean videoBean : bean) {
                    videoBean.height = (int) (SizeUtils.dp2px(200) + SizeUtils.dp2px(100) * Math.random());
                }
                mView.initAdapter(bean);
            }

            @Override
            public void fail(String msg) {
                Log.i("TagA", "msg:" + msg);
            }
        });
    }
}
